<?php

class Sfs_Form extends Zend_Form
{

    public  $standardElementDecorator = array(
		'ViewHelper',
    array('LabelError', array('escape'=>false)),
    array('HtmlTag', array('tag'=>'li'))
    );

    public  $buttonElementDecorator = array(
		'ViewHelper'
		);

		public  $standardGroupDecorator = array(
		'FormElements',
		array('HtmlTag', array('tag'=>'ol')),
		'Fieldset'
		);

		public $buttonGroupDecorator = array(
		'FormElements',
		'Fieldset'
		);

		public  $noElementDecorator = array(
		'ViewHelper'
		);


		public function __construct($options = null)
		{
		    // Path setting for custom classes MUST ALWAYS be first!
		    $this->addElementPrefixPath('Sfs_Form_Decorator', 'Sfs/Form/Decorator/', 'decorator');
		    $this->addElementPrefixPath('Sfs_Filter', 'Sfs/Filter/', 'filter');
		    $this->addElementPrefixPath('Sfs_Validate', 'Sfs/Validate/', 'validate');
		    $this->addPrefixPath('Sfs_Form_Element', 'Sfs/Form/Element/', 'element');

		    $this->_setupTranslation();

		    parent::__construct($options);

		    $this->setAttrib('accept-charset', 'UTF-8');
		    $this->setDecorators(array(
						'FormElements',
						'Form'
						));

		}

		protected function _setupTranslation()
		{
		    if (self::getDefaultTranslator()) {
		        //$front = Zend_Controller_Front::getInstance();
		        $class =  get_class($this);
		        $p = explode("_",$class);
		        $module = strtolower($p[0]);
		        $name = strtolower(end($p));
		        $tr_name = APPLICATION_PATH.'/modules/'.$module.'/languages/'.
		        self::getDefaultTranslator()->getLocale()."/forms/$name.php";

		        if (is_file($tr_name))
		        self::getDefaultTranslator()->addTranslation($tr_name);
		        return;
		    }

		    //$path = Bootstrap::$root . '/translate/forms.php';
		    //$translate = new Zend_Translate('array', $path, 'en');
		    //self::setDefaultTranslator($translate);
		}


}